package com.fwtai.web;

import com.fwtai.bean.PageFormData;
import com.fwtai.datasource.DaoHandle;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * 总公司商品访问数据库
 * @作者 田应平
 * @版本 v1.0
 * @创建时间 2023-04-07 11:08:26
 * @QQ号码 444141300
 * @Email service@yinlz.com
 * @官网 <url>http://www.fwtai.com</url>
*/
@Repository
public class GoodsDao{

  private final DaoHandle dao;

  public GoodsDao(final DaoHandle dao){
    this.dao = dao;
  }

  public int add(final PageFormData formData){
    return dao.execute("goods.add",formData);
  }

  public int edit(final PageFormData formData){
    return dao.execute("goods.edit",formData);
  }

  public HashMap<String,String> queryExistById(final long kid){
    return dao.queryForHashMapString("goods.queryExistById",kid);
  }

  public List<HashMap<String,String>> queryFiles(final long[] lists){
    return dao.queryForListString("goods.queryFiles",lists);
  }

  public HashMap<String,Object> queryById(final long kid){
    return dao.queryForHashMap("goods.queryById",kid);
  }

  public int delById(final long kid){
    return dao.execute("goods.deletedById",kid);
  }

  public int delByKeys(final long[] list){
    return dao.execute("goods.delByKeys",list);
  }

  public List<HashMap<String,Object>> getListData(final PageFormData formData){
    return dao.queryForListHashMap("goods.listData",formData);
  }

  public Integer getListTotal(final PageFormData formData){
    return dao.queryForInteger("goods.listTotal",formData);
  }

  //获取表goods的字段contract_type的下拉框列动态值选项的数据
  public List<HashMap<String,Object>> getContract_type(){
    return dao.queryForListHashMap("goods.getContract_type");
  }

  public int editIntegral(final ArrayList<HashMap<String,Object>> list){
    return dao.execute("goods.editIntegral",list);
  }
}